package com.youzhi.message.kafka;

import cn.hutool.core.util.StrUtil;
import com.youzhi.message.ChannelHolder;
import com.youzhi.message.dto.MessageType;

import java.util.Map;

public class KickOffLineHandler implements IKafkaMessageHandler {


    @Override
    public String getHandlerType() {
        return MessageType.kick_off_line.type;
    }


    /**
     * {"webSocketId":"4973bd7b-7b88-4e5a-929b-33353dcb0c6a"}
     *
     * @param data
     */
    @Override
    public void handle(Map<String, Object> data) {
        String websocketId = data.get("webSocketId").toString();
        if (StrUtil.isNotEmpty(websocketId)) {
            ChannelHolder.broadCast(websocketId, "{\"type\":\"kick_off_line\"}");
        }

    }
}
